<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var name test  以后避开这两个名字 防止引起不必要的错误
        // 核心是 子类的原型直接指向父类的原型 
        function Person(name,age){
            this.name = name;
            this.age = age;
        }

        Person.prototype.sayHello = function(){
            console.log('hello world');
        }


        function Student(gender){
            this.gender = gender;
        }

        Student.prototype = Person.prototype;
     
        
        var s1 = new Student('男');
        console.log(s1);

        // 子类没有自己的原型了 直接使用父类的原型 


        // 寄生继承的优化  

    </script>
</body>
</html>